import store from '@/store'
export default {
    inserted(el, binding) {
        const { value: permissionRoles } = binding;
        const roles = store.getters.roles;
        if (permissionRoles && permissionRoles instanceof Array && permissionRoles.length) {
            const hasPermission = roles.some(role => {
                return permissionRoles.includes(role)
            })
            if (!hasPermission) {
                el.parentNode && el.parentNode.removeChild(el);
            }
        } else {
            throw new Error('需要指定数组类型权限')
        }
    }
}